/****************************************************************************
 * 2025.4 阿桑的笔记本
 ****************************************************************************/

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using QFramework;

namespace QFramework.Example
{
	public partial class GameSettings : UIElement,IController,ICanBtnOnclickEvents
	{
		private void Awake()
		{

            MusicSlider.value = DataManager.Instance.gameDatas.MusicValue;
            BtnOnClicks();
        }

		protected override void OnBeforeDestroy()
		{
		}

        public IArchitecture GetArchitecture()
        {
		   return	Global.Interface;
        }

        public void BtnOnClicks()
        {
            ///调整音量保存数据
			SaveSettingsBtn.onClick.AddListener(() =>
			{
				DataManager.Instance.gameDatas.MusicValue = MusicSlider.value;
				DataManager.Instance.saveSystem.SaveData(DataManager.Instance.gameDatas, "gameData.json");
                this.Hide();
            });


            MusicSlider.onValueChanged.AddListener(value => 
            {
                DataManager.Instance.audioSource.volume = value;
            });



        }
    }
}